#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H

#include <QGraphicsPixmapItem>
#include <QObject>
#include <QPainterPath>

class GameObject : public QObject, public QGraphicsPixmapItem
{
    Q_OBJECT
public:
    explicit GameObject(QObject *parent = nullptr);

    //碰撞相关的函数
    void setCollisionShapeMode(QGraphicsPixmapItem::ShapeMode mode); // 设置碰撞检测的形状计算方式。
    void setCustomCollisionShapeMode(const QPainterPath &path);      // 设置自定义碰撞形状
    bool collidesWith(const GameObject *other) const;                // 碰撞检测

    // 基础更新方法
    virtual void update(float deltaTime);

    // 对象类型标识
    //virtual QString type() const = 0;

protected:
    QPainterPath shape() const override; // 重写QGraphicsItem的shape函数

    QPainterPath m_customCollisionPath; // 自定义的碰撞形状
    bool m_useCustomShape = false;      // 是否启用了自定义的碰撞形状
};

#endif // GAMEOBJECT_H
